package com.meta.nd.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

public class Fv {
	private long id;
	private String code;
	private String name;
	private String dataType;
	private Object value;
	
	public long getId() {
		
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDataType() {
		return dataType;
	}
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}	
	
	public void setRawInt(Integer value) {
		
		this.value = value;
		
	}
	
	public  int getRawInt( ) {
	
		if ( this.value == null )
			return 0;
		else
			return ((Integer) this.value ).intValue();
	}
	
	public void setRawLong( Long value) {
		this.value = value;
		
	}
	
	public  long getRawLong( ) {
		
		if ( this.value == null )
			return 0;
		else
			return ((Long) this.value ).longValue();
	}
	
	
	public void setRawDouble(double value) {
		this.value = value;
	}
	
	public  double getRawDouble( ) {
	
		if ( this.value == null )
			return 0.0;
		else
			return ((Double) value ).doubleValue();
	}
	
	public void setRawString( String value) {
		this.value = value;
	}
	
	public  String getRawString( ) {
		
		return (String) this.value;
	}
	
	public Boolean getRawBool() {
		if ( this.value == null)
			return false;
		else
			return (Boolean) this.value;
	}
	
	public void setRawBool(Boolean value ) {
		if ( value == null)
			this.value = false;
		else
			this.value = value;
	}
	
	
	public void setRawDate( Date value) {
		this.value = value;
	}
	
	public  Date getRawDate() {
		
		return (Date) this.value;
	}

	public List<String> getRawStringList(){
		return (List<String>) this.value;
	}

	@JsonIgnore
	public String stringList2String(){
		List<String> strList = (List<String>)this.value;
		if ( strList == null)
			return null;
		StringBuffer sb = new StringBuffer();
		for( String str : strList){
			if (StringUtils.isEmpty(str))
				continue;
			if ( sb.length() == 0)
				sb.append(str);
			else
				sb.append(",").append(str);
		}
		return sb.toString();
	}
	
	
}
